package com.since.data_structure.binarytree;

import com.since.data_structure.binarytree.node.Node;

/**
 * Created by Sincerity on 2020/5/16.
 * 描述：
 */
class BinaryTreeTest {
    public static void main(String[] args) {
        BinaryTree tree = new BinaryTree();
       Node root = new Node(1);
        Node node2 = new Node(2);
        Node node3 = new Node(3);
        Node node4 = new Node(4);
        Node node5 = new Node(5);
        root.left = node2;
        root.right = node3;
        node3.right = node4;
        node3.left = node5;
        tree.setRoot(root);
//        System.out.println("前序");
//        tree.preOrder();
        System.out.println("中序");
        tree.infixOrder();
        System.out.println("后序");
        tree.postOrder();
        //
        System.out.println("前序" + tree.preOrderSearch(5));
        System.out.println("中序" + tree.infixSearch(5));
        System.out.println("后序" + tree.postSearch(5));
        System.out.println("删除节点");
        tree.deleteNode(2);
        System.out.println("前序");
        tree.preOrder();
    }
}
